import QtQuick 2.4
import QtQuick.Controls 2.4
import QtQuick.Controls.Basic 2.4

ScrollBar {
    id: control
    property var theme: p_theme.currentTheme()
    property bool rolling: false
    active: true
    hoverEnabled: true
    policy: parent.contentHeight > parent.height ? ScrollBar.AlwaysOn : ScrollBar.AlwaysOff
    minimumSize: 0.1
    background: Rectangle {
        color: "#1f" + theme.subBackgroundColor2
        radius: width / 2
    }
    onVisualPositionChanged: {
        rolling = true;
        delayedCloseRolling();
    }

    function delayedCloseRolling() {
        timer.running = false;
        timer.running = true;
    }
    Timer {
        id: timer
        interval: 600 // 1秒
        running: true
        repeat: false
        onTriggered: {
            control.rolling = false;
        }
    }

    contentItem: Rectangle {

        implicitWidth: 10
        implicitHeight: 50
        color: (control.pressed || control.rolling || control.hovered) ? theme.fontColor : "#4F" + theme.subBackgroundColor2
        radius: width / 2

        Behavior on color {
            ColorAnimation {}
        }
    }
}
